package com.graduation.lastproject.controller.admin;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

@Controller
/*@RequestMapping(value = "helloword" )*/     //这个地方加这个会影响什么 我忘了 难受
public class index {

    @RequestMapping(value = "hello")
    public  String hello(HttpServletRequest request,String id){
        /*String index="echarts";*/
        String index1=request.getParameter("id");
        request.setAttribute("id",index1);
        Map<String, Object> map = parameters(request);
        String index=map.get("id")!= null ? map.get("id").toString() : "login";
        request.setAttribute("login",index);
        return "index";
    }
    @RequestMapping(value = "helloo")
    public String hello()
    {
        return "echarts";
    }

    @RequestMapping(value = "hellooo")
    public String helloo()
    {
        return "login";
    }


    /** request转map */
    private final Map<String, Object> parameters(HttpServletRequest request) {
        Map<String, Object> parameters = new HashMap<String, Object>();
        if (request != null) {
            Enumeration<String> keys = request.getParameterNames();
            while (keys.hasMoreElements()) {
                String key = keys.nextElement();
                try {
                    parameters.put(key, request.getParameter(key));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return parameters;
    }

}
